package com.cloud.mall.usr.service;

import com.cloud.mall.api.CommonPage;
import com.cloud.mall.base.BaseResponse;
import com.cloud.mall.user.input.UmsResourceCategoryInpDTO;
import com.cloud.mall.user.input.UmsRoleInpDTO;
import com.cloud.mall.user.output.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "用户角色管理接口")
@RequestMapping("/role")
public interface UmsRoleService {

    @ApiOperation("添加角色")
    @PostMapping("/create")
    BaseResponse create(@RequestBody UmsRoleInpDTO umsRoleInpDTO);

    @ApiOperation("修改角色")
    @PostMapping("/update/{id}")
    BaseResponse update(@PathVariable Long id,
                        @RequestBody UmsRoleInpDTO umsRoleInpDTO);

    @ApiOperation("批量删除角色")
    @PostMapping("/delete")
    BaseResponse delete(@RequestParam("ids") List<Long> ids);

    @ApiOperation("获取相应角色权限")
    @GetMapping("/permission/{roleId}")
    BaseResponse<List<UmsPermissionOut>> getPermissionList(@PathVariable Long roleId);

    @ApiOperation("修改角色权限")
    @PostMapping("/permission/update")
    BaseResponse updatePermission(@RequestParam Long roleId,
                                         @RequestParam("permissionIds") List<Long> permissionIds);

    @ApiOperation("获取所有角色")
    @GetMapping("/listAll")
    BaseResponse<List<UmsRoleOut>> listAll();

    @ApiOperation("根据角色名称分页获取角色列表")
    @GetMapping("/list")
    BaseResponse<CommonPage<UmsRoleOut>> list(@RequestParam(value = "keyword", required = false) String keyword,
                                              @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
                                              @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum);
    @ApiOperation("修改角色状态")
    @PostMapping("/updateStatus/{id}")
    BaseResponse updateStatus(@PathVariable Long id, @RequestParam(value = "status") Integer status);

    @ApiOperation("获取角色相关菜单")
    @GetMapping("/listMenu/{roleId}")
    BaseResponse<List<UmsMenuOut>> listMenu(@PathVariable Long roleId) ;

    @ApiOperation("获取角色相关资源")
    @GetMapping("/listResource/{roleId}")
    BaseResponse<List<UmsResourceOut>> listResource(@PathVariable Long roleId);

    @ApiOperation("给角色分配菜单")
    @PostMapping("/allocMenu")
    BaseResponse allocMenu(@RequestParam Long roleId, @RequestParam List<Long> menuIds);

    @ApiOperation("给角色分配资源")
    @PostMapping("/allocResource")
    BaseResponse allocResource(@RequestParam Long roleId, @RequestParam List<Long> resourceIds);


}
